# encoding=utf-8
# author:梁子龙
from fastapi import Request
from sqlalchemy.orm import Session


def get_db(request: Request) -> Session:
    """

    :param request:
    :return:
    """
    return request.state.db


class CommonQueryParams:
    """
    分页
    """

    def __init__(self, offset: int = 1, limit: int = 10):
        self.offset = offset
        if self.offset < 0:
            self.offset = 0
        self.limit = limit
        if self.limit <= 0:
            self.limit = 0
